package com.feihong.txgw.tx_precenter;

import com.feihong.txgw.inter.contract.setting.ISettingContract;
import com.feihong.txgw.tx_model.SettingMainModel;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName SettingMainPrecenter
 * @package com.feihong.txgw.tx_precenter
 * @data 2018/5/7 16:19
 * @Describe
 * @Change
 */
public class SettingMainPrecenter extends ISettingContract.AbSettingMainPrecenter {

    public static SettingMainPrecenter create(){
        return new SettingMainPrecenter();
    }
    @Override
    public void logout() {
        mIModel.logout().subscribe(new Observer<String>() {
            @Override
            public void onSubscribe(Disposable d) {
                mRxManager.register(d);
            }

            @Override
            public void onNext(String o) {
                mIView.logoutResult(o);
            }

            @Override
            public void onError(Throwable e) {
                mIView.loadDataError();
            }

            @Override
            public void onComplete() {
                mIView.loadDataComplated();
            }
        });
    }

    @Override
    public ISettingContract.ISettingMainModel getModel() {
        return SettingMainModel.create();
    }

    @Override
    public void onStart() {

    }
}
